CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

IF (NOT TARGET FLATBUFFER::H)
    ADD_LIBRARY(FLATBUFFER::H INTERFACE IMPORTED)
    TARGET_INCLUDE_DIRECTORIES(FLATBUFFER::H INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/windows/include")
ENDIF ()

IF (NOT TARGET FLATBUFFER::LIB)
    FIND_LIBRARY(FLATBUFFER_LIB NAMES flatbuffers PATHS ${CMAKE_CURRENT_SOURCE_DIR}/windows/lib NO_DEFAULT_PATH)
    ADD_LIBRARY(FLATBUFFER::LIB STATIC IMPORTED)
    SET_TARGET_PROPERTIES(FLATBUFFER::LIB PROPERTIES IMPORTED_LOCATION "${FLATBUFFER_LIB}")
ENDIF()

IF (NOT TARGET LIBRARIES::FLATBUFFER)
    ADD_LIBRARY(LIBRARIES::FLATBUFFER INTERFACE IMPORTED GLOBAL)
    TARGET_LINK_LIBRARIES(LIBRARIES::FLATBUFFER INTERFACE
            FLATBUFFER::H
            FLATBUFFER::LIB)
ENDIF()